<template>
  <el-dialog
    v-model="is_show"
    :width="width"
    :show-close="false"
    class="recruitment-dialog"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    @closed="closeDialog"
  >
    <template #header>
      <div class="dialog-header-container">
        <div class="dialog-header-left">
          <div class="dialog-icon">
            <img
              src="https://ai-public.mastergo.com/ai/img_res/76cb9bf7a6b8f61d27ea0a03e6a3d7cf.jpg"
              alt="Icon"
            />
          </div>
          <div class="dialog-title-container">
            <div v-if="!!title" class="dialog-title">{{ title }}</div>
            <div class="dialog-subtitle">{{ content }}</div>
          </div>
        </div>
        <div class="dialog-close" @click="closeDialog">
          <el-icon><Close /></el-icon>
        </div>
      </div>
    </template>
    <div class="padding-tb-sm">
      <slot></slot>
    </div>

    <template #footer>
      <div class="padding-sm">
        <slot name="footer"></slot>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
  import { ref, watch } from 'vue'

  const props = defineProps({
    title: {
      type: String,
      default: '',
    },
    content: {
      type: String,
      default: '万花商供应链-提供多种优质服务',
    },
    titleList: {
      type: Array,
      default: () => [],
    },
    width: {
      type: String,
      default: '500px',
    },
    close: {
      type: Function,
      default: () => {},
    },
    modelValue: {
      type: Boolean,
    },
  })

  const emit = defineEmits(['update:modelValue', 'close'])

  const is_show = ref(props.modelValue)

  watch(
    () => props.modelValue,
    (newVal) => {
      is_show.value = newVal
    }
  )

  watch(is_show, (newVal) => {
    emit('update:modelValue', newVal)
  })

  const closeDialog = () => {
    is_show.value = false
    emit('close')
  }
</script>

<style lang="scss">
  .recruitment-dialog {
    padding: 0 !important;
    border-radius: 20px;
    :deep(.el-dialog) {
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }

    :deep(.el-dialog__header) {
      padding: 0 !important;
      margin: 0 !important;
    }

    :deep(.el-dialog__body) {
      padding: 20px;
    }

    :deep(.el-dialog__footer) {
      border-top: 1px solid #eaedf1;
      padding: 15px 20px;
    }
  }
</style>

<style lang="scss" scoped>
  .dialog-header-container {
    background: linear-gradient(135deg, #2b3a67, #1e4d92);
    position: relative;
    padding: 24px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    overflow: hidden;
    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: url('https://mastergo.com/ai/api/search-image?query=abstract technology background with glowing lines and dots, creating a network pattern, dark blue and white color scheme, subtle geometric shapes, modern and minimalist design&width=800&height=400&orientation=landscape&flag=76cb9bf7a6b8f61d27ea0a03e6a3d7cf')
        center/cover;
      opacity: 0.1;
      animation: pulse-33be1828 3s infinite;
    }
  }

  .dialog-header-left {
    display: flex;
    align-items: center;
  }

  .dialog-icon {
    margin-right: 15px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);

    img {
      width: 28px;
      height: 28px;
      object-fit: contain;
    }
  }

  .dialog-title-container {
    display: flex;
    flex-direction: column;
  }

  .dialog-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
  }

  .dialog-subtitle {
    font-size: 12px;
    opacity: 0.8;
  }

  .dialog-close {
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;

    &:hover {
      background-color: rgba(255, 255, 255, 0.3);
      transform: rotate(90deg);
    }

    i {
      font-size: 18px;
    }
  }
</style>
